<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <style>
        * {
            margin: 0;
            padding: 0;
        }

        .title h2 span {
            color: #2497ea;
        }

        #app {
            padding: 20px;
            background-color: aqua;
            height: 896px;
        }

        .inputText {
            display: flex;
            justify-content: space-between;
        }

        .inputText input {
            outline: none;
            border-radius: 20px;
            line-height: 40px;
            box-sizing: border-box;
            padding-left: 20px;
            width: 334px;
            background-color: #f3f3f3;
        }

        .inputText div {
            line-height: 40px;
            color: #2497ea;
        }

        .find {
            display: flex;
            flex-wrap: wrap;
        }

        .find div {
            line-height: 30px;
            background-color: #f3f3f3;
            margin-top: 10px;
            margin-right: 10px;
            padding: 10px;
        }

        .list {
            margin-top: 30px;
            display: flex;
            flex-wrap: wrap;
        }
        .list div{
            padding: 10px;
            background-color: #f1f1f2;
            margin-right: 10px;
            margin-bottom: 10px;
        }

        .hostory {
            margin-top: 30px;
        }
    </style>
</head>

<body>
    <div id="app">
        <div class="title">
            <h2> <span>
                    < </span> 搜索 </h2>
        </div>
        <div class="inputText">
            <input type="text" placeholder="🔍搜索商家、商品名称" v-model="inputText">
            <div @click="add">搜索</div>
        </div>
        <h3 class="hostory">历史搜索</h3>
        <div class="list">
            <div>天天鲜挪威三文鱼</div>
            <div :class="{task:true,finished:item.status}" v-for="(item,index) in tasklist" :key="index">
                <div class="name">{{item.name}}</div>
            </div>
        </div>
        <h3 class="hostory">搜索发现</h3>
        <div class="find">
            <div>麻辣烫</div>
            <div>米线</div>
            <div>披萨</div>
            <div>蛋糕</div>
            <div>汉堡</div>
            <div>腊八粥</div>
            <div>烤肉办法</div>
            <div>炸鸡</div>
            <div> 咪多美（遇阳路店） </div>
        </div>
    </div>
</body>

</html>
<script src="./vue-2.5.21.js"></script>
<script>
    var v = new Vue({
        el: '#app',
        data: {
            inputText: '',
            tasklist: []
        },
        methods: {
            add() {
                if (this.inputText) {
                    var obj = {
                        id: this.tasklist.length
                            + 1, name: this.inputText, status: false
                    }
                    this.tasklist.push(obj)
                    this.inputText = '';
                }
            },
            changeStatus(item) {
                item.status = !item.status
            }
        }
    })
</script>